<<!DOCTYPE html>
<html>
<head>
	<title>FormTest</title>
	<script type="text/javascript" src='../EventUtil.js'></script>
	<script type="text/javascript" src='../FormUtil.js'></script>
</head>
<body>

<form id="text">
<input type="text" size="25" value="initvalue" maxlength="50" name="textbox1" /><br/>

<textarea rows="10" cols="15" name="textbox2">init value</textarea><br/>

<select name="location" id="selLocation">
<option value="Sunnyvale, CA">Sunnyvale</option>
<option value="Los Angeles, CA">Los Angeles</option>
<option value="Mountain View, CA">Mountain View</option>
<option value="">China</option>
<option>Australia</option>
<br/>
</select>
<br/>

<button margin-top='100px' type="submit"> 提交 </button>

</form>

<script type="text/javascript">
	var form = document.getElementById('text');
	EventUtil.addHandler(form,'submit',function(event){
		var url = FormUtil.serialize(form);
		// console.log(url);
		console.log('url');
	});
	// var tb1=form.elements[0];
	// var tb2=form.elements[1];
	// var selectbox = document.getElementById('selLocation')

	//获得焦点时选中
/*	EventUtil.addHandler(tb1, "focus", function(event){
		var target = EventUtil.getTarge(event);
		target.select();
		clearSelectbox(selectbox);
	});
	EventUtil.addHandler(tb1, "select", function(event){
		// alert(tb1.value);
	});

	function clearSelectbox(selectbox){
	for(var i=0, len=selectbox.options.length; i < len; i++){
	selectbox.remove(0);
	}
	}*/



</script>	
<!-- 

<form id="myForm">

<textarea width='200px' height='200px' value ='textarea'></textarea>

	通用提交按钮
<input type="submit" value="Submit Form">
图像按钮
<input type="image" src="graph.png">

自定义提交按钮
<button type="submit">Submit Form</button>

</form>

<script type="text/javascript">
	var form = document.getElementById("myForm");
EventUtil.addHandler(form, "submit", function(event){
	// 先提交表单
    //阻止默认事件；如果提交失败再恢复呗
	EventUtil.preventDefault(event);
});

EventUtil.addHandler(form,'reset',function(event){
	ii.disable=true;
});

var textbox = document.forms[1].elements[0];

EventUtil.addHandler(textbox, "focus", function(event){

var target = EventUtil.getTarge(event);

if (target.style.backgroundColor != "red"){
  target.style.backgroundColor = "yellow";
}});

EventUtil.addHandler(textbox, "blur", function(event){
var target = EventUtil.getTarge(event);
if (/[^\d]/.test(target.value)){
target.style.backgroundColor = "red";
} else {
target.style.backgroundColor = "";
}
});

EventUtil.addHandler(textbox, "change", function(event){
var target = EventUtil.getTarge(event);
if (/[^\d]/.test(target.value)){
target.style.backgroundColor = "red";
} else {
target.style.backgroundColor = "";
}
});
</script> -->
</body>
</html>